package com.kaifamiao.implicit.filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

@WebFilter( urlPatterns = "/*" ,
            dispatcherTypes = { DispatcherType.REQUEST , DispatcherType.FORWARD , DispatcherType.INCLUDE })
public class DispatchFilter implements Filter {

    @Override
    public void doFilter(ServletRequest req , ServletResponse resp, FilterChain chain)
            throws IOException, ServletException {

        HttpServletRequest request = (HttpServletRequest)req ;
        String uri = request.getRequestURI();
        DispatcherType type = request.getDispatcherType();

        System.out.println( type + " : "+ uri );

        chain.doFilter( req , resp );

    }

}
